home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / gfx / x11 / x3270_3_2_16.lha / amiga_src / globals.h < prev    next >
C/C++ Source or Header  |  2001-06-24  |  7KB  |  275 lines

  1. /*
  2.  * Modifications Copyright 1993, 1994, 1995, 1996, 1999, 2000 by Paul Mattes.
  3.  * Copyright 1990 by Jeff Sparkes.
  4.  *  Permission to use, copy, modify, and distribute this software and its
  5.  *  documentation for any purpose and without fee is hereby granted,
  6.  *  provided that the above copyright notice appear in all copies and that
  7.  *  both that copyright notice and this permission notice appear in
  8.  *  supporting documentation.
  9.  */
  10.  
  11. /*
  12.  *    globals.h
  13.  *        Common definitions for x3270.
  14.  */
  15.  
  16.  
  17. /* Optional parts. */
  18. #include "parts.h"
  19. #if defined(X3270_TN3270E) && !defined(X3270_ANSI) /*[*/
  20. #define X3270_ANSI    1    /* RFC2355 requires NVT mode */
  21. #endif /*]*/
  22.  
  23. /*
  24.  * OS-specific #defines.  Except for the blocking-connect workarounds, these
  25.  * should be replaced with autoconf probes as soon as possible.
  26.  */
  27.  
  28. /*
  29.  * BLOCKING_CONNECT_ONLY
  30.  *   Use only blocking sockets.
  31.  */
  32. #if defined(sco) /*[*/
  33. #define BLOCKING_CONNECT_ONLY    1
  34. #endif /*]*/
  35.  
  36. #ifdef AMIGA /*[*/
  37. #define BLOCKING_CONNECT_ONLY    1
  38. #endif /*]*/
  39.  
  40. #if defined(apollo) /*[*/
  41. #define BLOCKING_CONNECT_ONLY    1
  42. #endif /*]*/
  43.  
  44. /*
  45.  * Compiler-specific #defines.
  46.  */
  47.  
  48. /* 'unused' explicitly flags an unused parameter */
  49. #if defined(__GNUC__) /*[*/
  50. #define unused __attribute__((__unused__))
  51. #else /*][*/
  52. #define unused /* nothing */
  53. #endif /*]*/
  54.  
  55.  
  56. #ifdef AMIGA
  57. #include <sys/time.h>            /* System time-related data types */
  58. #include <sys/tcp_types.h>
  59. #endif
  60.  
  61. /*
  62.  * Prerequisite #includes.
  63.  */
  64. #include <stdio.h>            /* Unix standard I/O library */
  65. #include <stdlib.h>            /* Other Unix library functions */
  66. #include <unistd.h>            /* Unix system calls */
  67. #include <ctype.h>            /* Character classes */
  68. #include <string.h>            /* String manipulations */
  69. #include <sys/types.h>            /* Basic system data types */
  70. #include <sys/time.h>            /* System time-related data types */
  71. #include "localdefs.h"            /* {s,tcl,c}3270-specific defines */
  72. #include "conf.h"            /* autoconf settings */
  73.  
  74. /* Local process (-e) header files. */
  75. #if defined(X3270_LOCAL_PROCESS) && defined(HAVE_LIBUTIL) /*[*/
  76. #define LOCAL_PROCESS    1
  77. #include <termios.h>
  78. #if defined(HAVE_PTY_H) /*[*/
  79. #include <pty.h>
  80. #endif /*]*/
  81. #if defined(HAVE_LIBUTIL_H) /*[*/
  82. #include <libutil.h>
  83. #endif /*]*/
  84. #if defined(HAVE_UTIL_H) /*[*/
  85. #include <util.h>
  86. #endif /*]*/
  87. #endif /*]*/
  88.  
  89. /* Simple global variables */
  90.  
  91. extern int        COLS;
  92. extern int        ROWS;
  93. #if defined(X3270_DISPLAY) /*[*/
  94. extern Atom        a_3270, a_registry, a_iso8859, a_ISO8859, a_encoding,
  95.                 a_1;
  96. extern XtAppContext    appcontext;
  97. #endif /*]*/
  98. extern const char    *build;
  99. extern int        children;
  100. extern char        *connected_lu;
  101. extern char        *connected_type;
  102. extern char        *current_host;
  103. extern unsigned short    current_port;
  104. extern Boolean        *debugging_font;
  105. extern char        *efontname;
  106. extern Boolean        ever_3270;
  107. extern Boolean        exiting;
  108. extern Boolean        *extended_3270font;
  109. extern Boolean        flipped;
  110. extern char        *full_current_host;
  111. extern char        full_model_name[];
  112. extern char        *hostname;
  113. extern Boolean        *latin1_font;
  114. extern char        luname[];
  115. #if defined(LOCAL_PROCESS) /*[*/
  116. extern Boolean        local_process;
  117. #endif /*]*/
  118. extern int        maxCOLS;
  119. extern int        maxROWS;
  120. extern char        *model_name;
  121. extern int        model_num;
  122. extern Boolean        non_tn3270e_host;
  123. extern int        ov_cols, ov_rows;
  124. extern Boolean        passthru_host;
  125. extern char        *programname;
  126. extern char        *reconnect_host;
  127. extern int        screen_depth;
  128. extern Boolean        scroll_initted;
  129. extern Boolean        shifted;
  130. extern Boolean        *standard_font;
  131. extern Boolean        std_ds_host;
  132. extern char        *termtype;
  133. extern Widget        toplevel;
  134.  
  135. #if defined(X3270_DISPLAY) /*[*/
  136. extern Atom        a_delete_me;
  137. extern Atom        a_save_yourself;
  138. extern Atom        a_state;
  139. extern Display        *display;
  140. extern Pixmap        gray;
  141. extern Pixel        keypadbg_pixel;
  142. extern XrmDatabase    rdb;
  143. extern Window        root_window;
  144. #endif /*]*/
  145.  
  146. /* Data types and complex global variables */
  147.  
  148. /*   connection state */
  149. enum cstate {
  150.     NOT_CONNECTED,        /* no socket, unknown mode */
  151.     PENDING,        /* connection pending */
  152.     CONNECTED_INITIAL,    /* connected, no mode yet */
  153.     CONNECTED_ANSI,        /* connected in NVT ANSI mode */
  154.     CONNECTED_3270,        /* connected in old-style 3270 mode */
  155.     CONNECTED_INITIAL_E,    /* connected in TN3270E mode, unnegotiated */
  156.     CONNECTED_NVT,        /* connected in TN3270E mode, NVT mode */
  157.     CONNECTED_SSCP,        /* connected in TN3270E mode, SSCP-LU mode */
  158.     CONNECTED_TN3270E    /* connected in TN3270E mode, 3270 mode */
  159. };
  160. extern enum cstate cstate;
  161.  
  162. #define PCONNECTED    ((int)cstate >= (int)PENDING)
  163. #define HALF_CONNECTED    (cstate == PENDING)
  164. #define CONNECTED    ((int)cstate >= (int)CONNECTED_INITIAL)
  165. #define IN_NEITHER    (cstate == CONNECTED_INITIAL)
  166. #define IN_ANSI        (cstate == CONNECTED_ANSI || cstate == CONNECTED_NVT)
  167. #define IN_3270        (cstate == CONNECTED_3270 || cstate == CONNECTED_TN3270E || cstate == CONNECTED_SSCP)
  168. #define IN_SSCP        (cstate == CONNECTED_SSCP)
  169. #define IN_TN3270E    (cstate == CONNECTED_TN3270E)
  170. #define IN_E        (cstate >= CONNECTED_INITIAL_E)
  171.  
  172. /*   keyboard modifer bitmap */
  173. #define ShiftKeyDown    0x01
  174. #define MetaKeyDown    0x02
  175. #define AltKeyDown    0x04
  176.  
  177. /*   toggle names */
  178. struct toggle_name {
  179.     const char *name;
  180.     int index;
  181. };
  182. extern struct toggle_name toggle_names[];
  183.  
  184. /*   extended attributes */
  185. struct ea {
  186.     unsigned char fg;    /* foreground color (0x00 or 0xf<n>) */
  187.     unsigned char bg;    /* background color (0x00 or 0xf<n>) */
  188.     unsigned char gr;    /* ANSI graphics rendition bits */
  189.     unsigned char cs;    /* character set (GE flag, or 0..2) */
  190. };
  191. #define GR_BLINK    0x01
  192. #define GR_REVERSE    0x02
  193. #define GR_UNDERLINE    0x04
  194. #define GR_INTENSIFY    0x08
  195.  
  196. #define CS_MASK        0x03    /* mask for specific character sets */
  197. #define CS_GE        0x04    /* cs flag for Graphic Escape */
  198.  
  199. /*
  200.  * Lightpen select test macro, includes configurable override of selectability
  201.  * of highlighted fields.
  202.  */
  203. #define FA_IS_SEL(fa) \
  204.     (FA_IS_SELECTABLE(fa) && \
  205.      (appres.highlight_select || !FA_IS_INTENSE(fa)))
  206.  
  207. /*   translation lists */
  208. struct trans_list {
  209.     char            *name;
  210.     char            *pathname;
  211.     Boolean            is_temp;
  212.     Boolean            from_server;
  213.     struct trans_list    *next;
  214. };
  215. extern struct trans_list *trans_list;
  216.  
  217. /*   font list */
  218. struct font_list {
  219.     char            *label;
  220.     char            *font;
  221.     struct font_list    *next;
  222. };
  223. extern struct font_list *font_list;
  224. extern int font_count;
  225.  
  226. /*   input key type */
  227. enum keytype { KT_STD, KT_GE };
  228.  
  229. /*   state changes */
  230. #define ST_HALF_CONNECT    0
  231. #define ST_CONNECT    1
  232. #define ST_3270_MODE    2
  233. #define ST_LINE_MODE    3
  234. #define ST_REMODEL    4
  235. #define ST_PRINTER    5
  236. #define ST_EXITING    6
  237. #define N_ST        7
  238.  
  239. /* Naming convention for private actions. */
  240. #define PA_PFX    "PA-"
  241.  
  242. /* Shorthand macros */
  243.  
  244. #define CN    ((char *) NULL)
  245. #define PN    ((XtPointer) NULL)
  246.  
  247. /* Configuration change masks. */
  248. #define NO_CHANGE    0x0000    /* no change */
  249. #define MODEL_CHANGE    0x0001    /* screen dimensions changed */
  250. #define FONT_CHANGE    0x0002    /* emulator font changed */
  251. #define COLOR_CHANGE    0x0004    /* color scheme or 3278/9 mode changed */
  252. #define SCROLL_CHANGE    0x0008    /* scrollbar snapped on or off */
  253. #define CHARSET_CHANGE    0x0010    /* character set changed */
  254. #define ALL_CHANGE    0xffff    /* everything changed */
  255.  
  256. /* Portability macros */
  257.  
  258. /*   Equivalent of setlinebuf */
  259.  
  260. #if defined(_IOLBF) /*[*/
  261. #define SETLINEBUF(s)    setvbuf(s, (char *)NULL, _IOLBF, BUFSIZ)
  262. #else /*][*/
  263. #define SETLINEBUF(s)    setlinebuf(s)
  264. #endif /*]*/
  265.  
  266. /*   Motorola version of gettimeofday */
  267.  
  268. #if defined(MOTOROLA)
  269. #define gettimeofday(tp,tz)    gettimeofday(tp)
  270. #endif
  271.  
  272. #ifdef AMIGA
  273. #include "amiga.h"
  274. #endif
  275.